top: prefer std::vector to temp xmalloc.
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 11 Oct 2014 19:33:32 +0000 (19:33 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 11 Oct 2014 19:33:32 +0000 (19:33 +0000)
cet: drop unused code.

gpsbabel/cet_util.cc
gpsbabel/cet_util.h
gpsbabel/tpo.cc

index b1566533f0c0babf315d44419e89501409b62064..db70e12752d53c20df4ea507768b7f48ce6ca3b0 100644 (file)
@@ -86,55 +86,6 @@ cet_str_any_to_any(const char* src, const cet_cs_vec_t* src_vec, const cet_cs_ve
   return c1;
 }
 
-/* %%% cet_valid_char %%%
- *
- * returnes 1 if convertable otherwise 0
- *
- */
-
-int
-cet_valid_char(const char* src, const cet_cs_vec_t* vec)
-{
-  int value;
-
-  const cet_cs_vec_t* v = (vec != NULL) ? vec : &cet_cs_vec_ansi_x3_4_1968;
-  return cet_char_to_ucs4(*src, v, &value);
-}
-
-
-#ifdef DEBUG_MEM
-
-void
-cet_check_cs(cet_cs_vec_t* vec)        /* test well sorted link & extra tables */
-{
-  cet_ucs4_link_t* link;
-
-  if ((link = (cet_ucs4_link_t*)vec->ucs4_link)) {
-    int i, j;
-
-    for (i = 0, j = 1; j < vec->ucs4_links; i++, j++) {
-      if (link[i].value >= link[j].value) {
-        printf(MYNAME ": checked 0x%04x with 0x%04x\n", link[i].value, link[j].value);
-        fatal(MYNAME ": \"%s\"-link-table unsorted !!!\n", vec->name);
-      }
-
-    }
-  }
-  if ((link = (cet_ucs4_link_t*)vec->ucs4_extra)) {
-    int i, j;
-
-    for (i = 0, j = 1; j < vec->ucs4_extras; i++, j++) {
-      if (link[i].value >= link[j].value) {
-        printf(MYNAME ": check 0x%04x with 0x%04x\n", link[i].value, link[j].value);
-        fatal(MYNAME ": \"%s\"-extra-table unsorted !!!\n", vec->name);
-      }
-
-    }
-  }
-}
-
-#endif
-
 static signed int
 cet_cs_alias_qsort_cb(const void* a, const void* b)
 {
@@ -537,37 +488,3 @@ cet_convert_strings(const cet_cs_vec_t* source, const cet_cs_vec_t* target, cons
     printf(", done.\n");
   }
 }
-
-
-/* %%% cet_fprintf / cet_vfprintf %%%
- *
- * - print any special hard-coded characters from inside a module - */
-
-int cet_gbfprintf(gbfile* stream, const cet_cs_vec_t* src_vec, const char* fmt, ...)
-{
-  int res;
-  char* cout;
-  va_list args;
-
-  va_start(args, fmt);
-  xvasprintf(&cout, fmt, args);
-  va_end(args);
-
-  if (global_opts.charset != src_vec) {
-    if (src_vec != &cet_cs_vec_utf8) {
-      char* ctemp = cet_str_any_to_utf8(cout, src_vec);
-      xfree(cout);
-      cout = ctemp;
-    }
-    if (global_opts.charset != &cet_cs_vec_utf8) {
-      char* ctemp = cet_str_utf8_to_any(cout, global_opts.charset);
-      xfree(cout);
-      cout = ctemp;
-    }
-  }
-
-  res = gbfprintf(stream, "%s", cout);
-  xfree(cout);
-
-  return res;
-}
index 934397e637e8fab5393dd09e4977fe1d0871422d..c8a58a95f7ef6fcf4b3549a3e2c3e4e10447e7ea 100644 (file)
@@ -54,7 +54,6 @@ extern cet_cs_vec_t cet_cs_vec_utf8;
 /* helpers */
 
 char* cet_str_any_to_any(const char* src, const cet_cs_vec_t* src_vec, const cet_cs_vec_t* dest_vec);
-int cet_valid_char(const char* src, const cet_cs_vec_t* vec);
 
 int cet_gbfprintf(gbfile* stream, const cet_cs_vec_t* src_vec, const char* fmt, ...);
 
index 159f19c9c2cca1c51c67bd2787209dd190310030..1e1bdaafd04c3db122ced26477725cf2bb7981dd 100644 (file)
@@ -258,7 +258,6 @@ void tpo_read_2_x(void)
   char buff[16];
   short track_count, waypoint_count;
   double first_lat, first_lon, lat_scale, lon_scale, amt;
-  short* lon_delta, *lat_delta;
   int i, j;
   route_head* track_temp;
   Waypoint* waypoint_temp;
@@ -312,10 +311,10 @@ void tpo_read_2_x(void)
     waypoint_count = gbfgetint16(tpo_file_in);
 
     /* allocate temporary memory for the waypoint deltas */
-    lon_delta = (short*) xmalloc(waypoint_count * sizeof(short));
-    lat_delta = (short*) xmalloc(waypoint_count * sizeof(short));
+    std::vector<short> lat_delta(waypoint_count);
+    std::vector<short> lon_delta(waypoint_count);
 
-    for (j=0; j<waypoint_count; j++) {
+    for (j = 0; j < waypoint_count; j++) {
 
       /* get this point's longitude delta from the first waypoint */
       lon_delta[j] = gbfgetint16(tpo_file_in);
@@ -340,7 +339,7 @@ void tpo_read_2_x(void)
     gbfread(&buff[0], 1, 2, tpo_file_in);
 
     /* multiply all the deltas by the scaling factors to determine the waypoint positions */
-    for (j=0; j<waypoint_count; j++) {
+    for (j = 0; j < waypoint_count; j++) {
 
       waypoint_temp = new Waypoint;
 
@@ -359,10 +358,6 @@ void tpo_read_2_x(void)
 
       track_add_wpt(track_temp, waypoint_temp);
     }
-
-    /* free temporary memory */
-    xfree(lon_delta);
-    xfree(lat_delta);
   }
 }
 
@@ -853,7 +848,6 @@ void tpo_process_waypoints(void)
     int lon;
     unsigned int altitude;
 
-
 //UNKNOWN DATA LENGTH
     (void)tpo_read_int(); // 0x00